/**
 * 支付回调记录实体类 - 支付平台回调通知的记录和处理状态
 *
 * 开发人员：徐少洋
 * 开发时间：2025-10-25 至 2025-10-28
 * 模块职责：定义支付回调记录的基本信息和业务属性，支持支付结果通知的记录和处理
 *
 * 技术要点：
 * - 多租户关联设计，与企业、支付订单实体关联
 * - 回调类型区分（notify/return）
 * - 签名验证状态和响应信息记录
 * - JSON格式的回调负载数据存储
 * - 审计字段自动维护回调时间
 *
 * 开发故事：负责支付回调记录实体的数据模型设计，与支付回调控制器深度配合，实现支付结果通知的完整记录和处理追踪。
 */
package com.pbl.entity;

import lombok.*;

import javax.persistence.*;
import java.time.LocalDateTime;

@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@Builder
@Entity
@Table(name = "payment_callbacks")
public class PaymentCallback {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "enterprise_id", nullable = false)
    private Enterprise enterprise;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "payment_order_id", nullable = false)
    private PaymentOrder paymentOrder;

    @Column(name = "notify_type", nullable = false, length = 16)
    private String notifyType; // notify/return

    @Lob
    @Column(name = "payload")
    private String payload; // store JSON text

    @Column(name = "sign", length = 64)
    private String sign;

    @Column(name = "sign_valid", nullable = false)
    private Integer signValid;

    @Column(name = "status_code")
    private Integer statusCode;

    @Column(name = "message", length = 255)
    private String message;

    @Column(name = "created_at", insertable = false, updatable = false)
    private LocalDateTime createdAt;
}
